<div class="container">
  <div class='col-sm-6 col-sm-offset-3'>
    <div class='panel panel-default'>
      <div class="panel-heading">
        找回密码
      </div>
      <div class="panel-body">
        <div class="form-group">
          <label for="email">电子邮箱</label>
          <input class='form-control' id='email' name='email' size='30' type='text' v-model="email"/>
        </div>
        <button class="btn btn-default" v-on:click="onSubmit">确认</button>
      </div>
    </div>
  </div>
</div>
<script>
  var appId = $('[name=app-id]').val();
  var pagePrefix = '<%= apiPrefix.page %>';
  var dataPrefix = '<%= apiPrefix.data %>';

  var vue = new Vue({
    el: '#app',
    data: {
      email: '',
      errorMsg: '',
      successMsg: ''
    },
    methods: {
      onSubmit: function() {
        vue.errorMsg = '';
        vue.successMsg = '';

        $.post( dataPrefix + '/user/createSearchPassword',
          { appId: appId,
            email: vue.email
          },
          function (result) {
            if (result.err) {
              vue.errorMsg = result.err;
            } else {
              vue.successMsg = result.msg;
            }
        });
      }
    }
  });
</script>
